public class SelectionSort {
    public static void sort(int arr[]) {
        /********** Begin *********/
        int count = 0;
        while(count < arr.length) {
            int tmp = count;
            for(int i = count; i < arr.length; i++) {
                if(arr[i] < arr[count]) {
                    int n = arr[i];
                    arr[i] = arr[count];
                    arr[count] = n;
                }
            }
            count++;
        }


        /********** End *********/
    }

    private static void print(int arr[]) {
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
        System.out.println();
    }

    public static void main(String[] args) {
        int[] arr = {1,5,2,7,8,3,4,5};
        sort(arr);
        print(arr);
    }
}
